<?php
	/* @var $placeholder Zend_View_Helper_Placeholder */
	$placeholder = $this->getHelper('Placeholder');
?>
<table class="kontorx_dataorder">
	<thead>
		<tr>
			<?php
				/* @var $column KontorX_DataGrid_Column_Interface */
				foreach ($this->columns as $k => $column): ?>
				<?php if (!$column->isGroup()):?>
					<th class="<?php print $column->class ?>" rowspan="<?php print $column->rowspan ?>" style="<?php print $column->style ?>"><?php print $column ?></th>
				<?php endif;?>
			<?php endforeach; ?>
		</tr>
		<tr class="filters">
			<?php foreach ($this->filters as $i => $filters):?>

			<?php $placeholder->placeholder("filter-$i")->captureStart();?>
			
				<?php
					/* @var $filter KontorX_DataGrid_Filter_Interface */
					foreach ($filters as $filter): ?>
				<span class="filter"><?php print $filter?></span>
				<?php endforeach; ?>
			
			<?php $placeholder->placeholder("filter-$i")->captureEnd();?>

			<?php 
				// sprawdz, czy jest ustawione filtrowanie
				if (count($filters)
						&& $filter->getColumn()->isGroup()) {
					// sprawdz, czy filter nalerzy do kolumny zgrupowanej
					// filt(er|ry) - miejsca w wierszu zgrupowania
					$placeholder->placeholder('filter-group')
						->set($placeholder->placeholder("filter-$i"));

				} else {
					// filt(er|ry) - tutaj jest ich miejsce :)
					print '<th>' . $placeholder->placeholder("filter-$i") . '</th>';
				}
			?>

			<?php endforeach; ?>
		</tr>
	</thead>
	<tbody>
		<?php $this->rowset->rewind()?>
		<?php
			/* @var $cellset KontorX_DataGrid_Adapter_Cellset_Interface */
			foreach ($this->rowset as $cellset): ?>

		<?php if ($cellset->hasGroupedCell()): ?>
		<tr class="groupColumn <?php print $this->cycle(array('odd','even'))?>">
			<td colspan="<?php print count($cellset)?>"><?php
				print $cellset->getGroupCell();
				// miejsca na filt(er|ry)
				print $placeholder->placeholder('filter-group');
			?></td>
		</tr>
		<?php endif; ?>

		<tr class="<?php print $this->cycle(array('odd','even'))?>">
			<?php
				/* @var $cell KontorX_DataGrid_Cell_Interface */
				foreach ($cellset as $cell): ?>
			<td><?php print $cell;?></td>
			<?php endforeach; ?>
		</tr>
		
		<?php endforeach; ?>
	</tbody>
	<tfoot>
		<tr>
			<td colspan="<?php print count($this->columns) ?>">
				<?php if ($this->paginator): ?>
				<?php print $this->paginationControl($this->paginator, 'Sliding','_partial/pagination.phtml', array('valuesQuery' => $this->valuesQuery)); ?>
				<?php endif;?>
			</td>
		</tr>
	</tfoot>
</table>